package com.lvdp.controller;


import com.lvdp.dto.Result;
import com.lvdp.service.IVoucherOrderService;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 辉哥
 * @since 2022-10-31
 */
@RestController
@RequestMapping("/voucher-order")
public class VoucherOrderController {

    @Resource
    private IVoucherOrderService iVoucherOrderService;

    /**
     * 购买普通的优惠券
     * @param voucherId 优惠券
     * @return 订单id
     */
    @PostMapping("buy/{id}")
    public Result buyVoucher(@PathVariable("id") Long voucherId) {
        return iVoucherOrderService.buyVoucher(voucherId);
    }

    /**
     * 限时秒杀
     * @param voucherId 秒杀优惠券
     * @return 订单id
     */
    @PostMapping("seckill/{id}")
    public Result seckillVoucher(@PathVariable("id") Long voucherId) {
        return iVoucherOrderService.seckillVoucher(voucherId);
    }
}
